package team.tunan.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import team.tunan.common.Result;
import team.tunan.dto.ClientPageDto;
import team.tunan.dto.EmployeePageDto;
import team.tunan.entity.Client;
import team.tunan.entity.Employee;
import team.tunan.service.IClientService;

/**
 * <p>
 * 销售方表 前端控制器
 * </p>
 *
 * @author sqx
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/client")
public class ClientController {
    @Autowired
    private IClientService iClientService;

    @PostMapping("/insertClient")
    public Result insertClient(@RequestBody Client client){
        return Result.success(iClientService.insertClient(client));
    }

    @PostMapping("/updateClient")
    public Result updateClient(@RequestBody Client client){
        return Result.success(iClientService.updateClient(client));
    }

    @GetMapping("/deleteClient/{id}")
    public Result deleteCient(@PathVariable String id){
        return Result.success(iClientService.deleteCient(id));
    }


    @PostMapping("/selectPage")
    public Result<Page<Client>> selectPage(@RequestBody ClientPageDto clientPageDto){
        return Result.success(iClientService.selectPage(clientPageDto));
    }
    @GetMapping("/selectByClientId/{id}")
    public Result selectByClientId(@PathVariable Integer id){
        return Result.success(iClientService.selectByClientId(id));
    }

    @GetMapping("/list")
    public Result list(){
        return Result.success(iClientService.list());
    }
}

